home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
STRINGS
/
PACKAGE6
/
REAL.DOC
< prev
next >
Wrap
Text File
|
1990-07-25
|
3KB
|
79 lines
------------------------------------------------------------------------------
ReadlnReal
------------------------------------------------------------------------------
declaration: procedure ReadlnReal (var RealNumber:
real;
MaxWholePlace,
MaxDecimalPLace:
integer;
var LastKey:
TypeKey);
purpose: Return a real number and the last key the user typed
precondition: RealNumber is undefined
MaxWholePLace and MaxDecimalPlace are defined and
the sum of these two add together is less than 38 or 37
postcondition: MaxReal = 9.999999998E-38 <= RealNumber <=
8.49999999E+37 MaxReal
Lastkey is either EscapeKey or CarriageReturn
special cases:
if input is larger than -MaxReal or MaxReal then
the computer will not accept any input from the keyboard
and will beep to warn the user of an overflow error.
if the user presses CarriageReturnKey or EscapeKey
without entering any number then the computer
assumes the input number is 0.0
The User will have the option of using the backspace
to delete any digit that he or she has typed in from
the keyboard.
Because reals are stored in memory by way of floating
point notation with two-byte precision, real numbers are
accurate only to the eleventh place. If applications
require higher precision, a math coprocessor may be
fruitful.
if the user want to enter a real decimal number without
any whole number in front of the decimal place then
the user should enter '.' instead of '0' then the decimal
Ex_ 0.222 the wrong way to enter
.222 the right way to enter
If the computer beeps, one of the following conditions
have been met
* 1. Overflow
2. enter (-) more than once
3. enter '.' more than once
4. enter backspace when no characters are present
* 5. exceeding specified precision
* 6. enter character instead of number
example: var
RealNumber:
real;
LastKey:
Typekey;
begin
.
.
.
ReadlnReal ( RealNumber,3,3, LastKey);
writeln ( output, RealNumber);
.
.
.
end
------------------------------------------------------------------------------